{{ define "template/scan_qr.html" }}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="Content-Type" content="text/html"/>
    <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no"/>
    <script src="/static/js/jquery-1.12.4.min.js"></script>
    <script type="application/javascript" src="/static/js/jquery.cookie-1.4.1.min.js"></script>
<!--    <script src="/static/js/qrscan.js"></script>-->
<!--    <script src="/static/js/UPNG.js"></script>-->
<!--    <script src="/static/js/jsQR.js"></script>-->
    <script src="/static/js/scanQrCode.js"></script>
    <link rel="stylesheet" href="/static/css/scanQrCode.css">
    <title>{{ .title }}</title>
</head>
<body>
<div class="headTitle col-md-12 col-xs-12 col-sm-12">
    <div class="head_logo">
        <a href="/admin"><img src="../../static/img/login_logo.png" alt=""></a>
    </div>
    <div class="user_menu">
        <ul>
            {{ if .name }}
            <li><a id="login"><img src="../../static/img/login32.png">欢迎您：</a></li>
            <li>
                <a id="registry" style="margin-left: -15px" onclick="showHideMenu()"><strong>{{ .name }}</strong></a>
            </li>
            {{ else }}
            <li>
                <a id="registry" style="margin-left: -15px" onclick="mobileLogin()"><strong>登录</strong></a>
            </li>
            {{end}}
        </ul>
    </div>
    <div class="userMenuPanel">
        <ul>
<!--            {{ if .success }}-->
<!--            <li id="myOrder" ><span onclick="myWorkOder()">我的工单</span></li>-->
<!--            {{ end }}-->
<!--            <hr>-->
            <li onclick="quitLogin()">退出登录</li>
        </ul>
    </div>
</div>
<!-- todo 扫码功能，开启即可扫码  -->
<!--
<div id="video"></div>
<div class="scanBtn">
    <button id="open">扫一扫</button>
    <button id="close">停止扫描</button>
</div>
-->
<div id="result" class="col-sm-12">
    <form class="form-horizontal scanForm">
        <div class="form-group">
            <label for="linkOrder" class="col-sm-2 control-label">关联单号：</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="linkOrder" placeholder="输入快递单号或生产单号">
            </div>
        </div>
        <div class="form-group">
            <label for="scanRet" class="col-sm-2 control-label">出货条码：</label>
            <div class="col-sm-10">
                <textarea class="form-control col-sm-9" name="scamRet" id="scanRet" rows="40" placeholder="请扫入出货产品上的条码"></textarea>
            </div>
            扫码数量：<span id="scanNum"></span> |
            本次出库总数：<span id="outLib"></span>
        </div>
        <!--  todo 如需要选择保修期，放开该注释即可
        <div class="form-group">
            <label for="WarrantyType" class="col-sm-2 control-label">保修期限：</label>
            <div class="col-sm-10">
                <select name="WarrantyType" id="WarrantyType" class="col-sm-10 form-control">
                    <option value=""></option>
                    <option value="1">1 &nbsp;个月</option>
                    <option value="2">6 &nbsp;个月</option>
                    <option value="3">12个月</option>
                </select>
            </div>
        </div>
        -->
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="button" class="btn btn-default" id="formBtn" onclick="formSubmit()">
                    提交
                </button>
            </div>
        </div>
    </form>
    <div class="errInfo">
        <span>jgjhghjg</span>
    </div>
</div>
<!-- 底部栏 -->
<div class="bottom col-md-12 col-xs-12">
    <div class="text_url">
            <span>友情链接:
                <a href="http://cn.lianliwork.com/">链力官网</a> |
                <a href="http://sh.lianliwork.com:8088">链力售后</a> |
                <a href="http://cn.lianliwork.com/about.html">关于我们</a> |
                <a href="https://v3.bootcss.com/">bootstrap</a> |
                <a href="https://www.baidu.com/">百度</a>
            </span>
        <span id="filing">备案号：<i>粤ICP备2022032841号</i></span>
    </div>
</div>
</body>
<script>
    var ds = null;
    var scan = new QRScan('video');

    document.getElementById('open').onclick = function () {
        scan.openScan();
        ds = window.setInterval(function () {
            startScan();
        }, 1500);
    };
    document.getElementById('close').onclick = function () {
        scan.closeScan();
        window.clearInterval(ds);
    };

    var re_div = document.getElementById('result');

    function startScan() {
        scan.getImgDecode(function (data) {
            // console.log(data);
            var p = document.createElement('p');
            if (data.success) {
                p.innerHTML = 'RESULT: ' + data.payload;
            } else {
                p.innerHTML = 'ERROR: ' + data.msg;
            }
            re_div.appendChild(p);
        });
    }
</script>
</html>
{{end}}